package com.example.flying_personnel_management_system.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class shjContorller {
    @Autowired
    com.example.flying_personnel_management_system.services.shj shj;

    @ResponseBody
    @RequestMapping(path = "seleOver", method = RequestMethod.POST)
    public JSONArray sele() {


        List<JSONObject> list = shj.sele();
        JSONArray array = JSONArray.parseArray(JSON.toJSONString(list));
        return array;
    }

    //查单个
    @ResponseBody
    @RequestMapping(path = "dangdu111", method = RequestMethod.POST)
    public JSONObject seled(@RequestBody String x) {
        JSONObject jsonObject = (JSONObject) JSONObject.parse(x);
        System.out.println(jsonObject.get("id"));

        String ji=jsonObject.get("id").toString();

        JSONObject object = shj.seled(ji);
 //
        return object;
    }


}

